<template>
	<view class="personal">
		<view class="title">
			<text class="text">我的</text>
			<image class="set-btn" src="/static/user/set.png" @click="personalInfo()" mode="aspectFill"></image>
		</view>
		<view class="stu-info">

			<view class="head">
				<image :src="utils.headImage(userInfo)" @click="utils.userDetails(userInfo.accountId, userInfo.userType)" mode="aspectFill"></image>
			</view>
			<view class="name">{{userInfo.name}}</view>
		</view>
		<view class="module-list">

			<view class="module-item flex" @click="pageJump(item)" v-for="(item) in module_list1" :key="item.icon" v-show="(item.icon=='queqin'&&userInfo.healther_teacher) || item.icon!='queqin'">
				<view class="left">
					<image class="icon-img" :src="`/static/user/${item.icon}.png`" mode="aspectFit"></image>
					<text class="name">{{item.text}}</text>
				</view>
                <view>
					<text class="tips" v-if="item.tips">{{item.tips}}</text>
					<uni-icons type="right" size="32rpx" color="#999"></uni-icons>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		onShow(){
			// #ifdef H5
			this.utils.showRedDot()
			// #endif
			this.getMeInfo();
			this.utils.setTTabBar()
		},
		data(){
			return {
				userInfo: {},
				module_list1: [{icon: 'zycs', text: '自我认知',tips: '世界级权威测试', url: '/pages/MBTI/test-home'}, {icon: 'wdxs', text: '我的学生', url: '/pages/teachers/all-student'}, {icon: 'wdfb', text: '我的发布', url: '/pages/teachers/my-publish'}, {icon: 'wdsh', text: '我的审核', url: '/pages/teachers/index', params: 1, type: 'tabBar'}, {icon: 'wdpj', text: '我的评价'}, {icon: 'wdtj', text: '我的推荐', url: '/pages/teachers/recommend-list'}, {icon: 'queqin', text: '缺勤情况', url: '/pages/teachers/absence-info'}],
			}
		},
		methods: {
			getWsToken(){
				this.api.get('user/getWsToken').then(res=>{
					if(res.data.state!='ok') return
					// let info = uni.getStorageSync('tokenObj')
					// info.wsToken = res.data.wsToken
					// uni.setStorageSync('tokenObj', info);
					// uni.$emit('login',{});
				})
			},
			getMeInfo(){
				this.api.get('user/getMeInfo').then(res=>{
					this.userInfo = res.data.user;
					getApp().globalData.userInfo = this.userInfo
				})
			},
			pageJump(item){
				if(!item.url){
					uni.showToast({
						title: '功能待开发',
						duration: 2000,
						icon: 'none',
						mask: true,
						position: 'bottom'
					})
					return;
				}
				if(item.params>=0){
					getApp().globalData.taskPageIndex = item.params;
				}
				
				if(item.type=='tabBar'){
					uni.switchTab({
						url: item.url
					})
				}else{
					uni.navigateTo({
						url: item.url
					})
				}
				
			},
			personalInfo(){
				let avatarUrl = this.userInfo.avatarUrl || ''
				uni.navigateTo({
					url: '/pages/personalInfo/personal-info?head='+avatarUrl+'&usertype=1'
				})
			}
		}
	}
</script>
<style lang="less" scoped>
	
	.personal{
		
		overflow: hidden;
		padding: 0rpx 32rpx 40rpx;
		box-sizing: border-box;
		background-image: url('~@/static/user/t-bg.png');
		background-repeat: no-repeat;
		background-size: contain;
		background-position: 0 0;
		box-sizing: border-box;
	}
	.title{
		padding: 16rpx 0;
		// #ifdef APP-PLUS
		padding-top: calc(16rpx + 28px);
		// #endif
		display: flex;
		justify-content: space-between;
		align-items: center;
		.text{
			font-size: 46rpx;
			color: #262E3F;
			font-weight: bold;
		}
	}
	.set-btn{
		width: 44rpx;
		height: 44rpx;
	}

	.uni-icons{
		margin-left: 16rpx;
	}
	.flex{
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	
	.stu-info{
		text-align: center;
		font-size: 0;
		padding-bottom: 32rpx;
		.head{
			image{
				width: 100rpx;
				height: 100rpx;
				border-radius: 50rpx;
				border: 6rpx solid #fff;
				box-sizing: border-box;
			}
		}
		.name{
			margin-top: 20rpx;
			font-weight: 600;
			font-size: 34rpx;
			line-height: 48rpx;
			color: #333333;
		}
		.num{
			margin-top: 10rpx;
			color: #666666;
			font-size: 20rpx;
		}
	}

	.module-list {
		margin-top: 40rpx;
		.left{
			display: flex;
			align-items: center;
		}
		.tips{
			font-size: 32rpx;
			color: #999999;
		}

		
	}
	.icon-img {
		width: 60rpx;
		height: 60rpx;
		margin-right: 32rpx;
	}
	.module-item{
		font-size: 0;
		height: 104rpx;
		position: relative;
		&::after{
			position: absolute;
			left: 92rpx;
			bottom: 0;
			content: '';
			width: 200%;
			height: 2rpx;
			background-color: #EEEEEE;
			transform: scale(0.5) translateX(-50%);
			
		}
		.name{
			font-size: 34rpx;
			color: #333333;
		}
	}
</style>